package com.mianle.userapi.util;

public enum JsonResponseEnum implements JsonResponse{


    SUCCESS(1,"操作成功"),
    PARAM_ERROR(2,"参数信息有误"),
    OPERATION_FAILED(3,"操作失败"),
    SERVER_INNER_ERROR(-1,"抱歉，服务器开小差了 T_T"),
    PARAM_INVALID(-2,"The value [%s] of the param [%s] is illegal"),
    HTTP_MESSAGE_CONVERT_FAIL(-3,"The http message can't convert to the param. the detail [%s]."),
    PARAM_BIND_ERROR(-4,"The http binding params occur exception. the detail [%s]."),
    UNAUTHORIZED(401,"未认证（签名错误）"),//未认证（签名错误）
    ;

    private Integer status;
    private String msg;

    JsonResponseEnum(Integer status, String msg){
        this.status = status;
        this.msg = msg;
    }


    @Override
    public JsonResponseData result(){
        return new JsonResponseData(status,msg);
    }

    public JsonResponseData result(Object o){
        return new JsonResponseData(status,msg,o);
    }


    public JsonResponseData formatMsg(Object... args){
        String newMsg = String.format(this.msg, args);
        return new JsonResponseData(status,newMsg);

    }


}
